#pragma once
#include"HashTable.h"
namespace zjs
{
	template <class K,class Hash = HashFun<K>>
	class unordered_set {
		struct KeyOfData 
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:

		typedef typename HashBucket<K, K, Hash, KeyOfData>::const_iterator iterator;
		typedef typename HashBucket<K, K, Hash, KeyOfData>::const_iterator const_iterator;

		pair<iterator,bool> insert(const K& data)
		{
			auto ret=_hb.insert(data);
			return make_pair(iterator(ret.first._cur, ret.first._hashi, ret.first._phb), ret.second);
		}

		iterator begin() const
		{
			return _hb.begin();
		}

		iterator end() const
		{
			return _hb.end();
		}

		iterator find(const K& key)
		{
			auto ret = _hb.find(key);
			return iterator(ret._cur, ret._hashi, ret._phb);
		}

		bool erase(const K& key)
		{
			return _hb.erase(key);
		}

		iterator erase(iterator pos)
		{
			return _hb.erase(pos);
		}


		size_t bucket_count()
		{
			return _hb.BucketCount();
		}

		size_t bucket_size(const K& key)
		{
			return _hb.BucketSize(key);
		}

		size_t size()const
		{
			return _hb.size();
		}

		bool empty()const
		{
			return _hb.empty();
		}
	private:
		HashBucket<K, K, Hash, KeyOfData>_hb;
	};
}